﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace QWeiBoN
{
    public class AppSetting
    {
        /// <summary>
        /// 查看类型---评论列表
        /// </summary>
        public static string CommentsListTypeKey
        {
            get
            {
                return "comments";
            }
        }

        /// <summary>
        /// 评论对应的原始文本
        /// </summary>
        public static string CommentsFatherText
        {
            get
            {
                return "commentfathertext";
            }
        }

        /// <summary>
        /// 评论的原始微博所属用户名称
        /// </summary>
        public static string CommentFatherName
        {
            get
            {
                return "commentfathername";
            }
        }

        /// <summary>
        /// 添加微博的类型查询---新微博，转播，回复
        /// </summary>
        public static string AddStatusTypeKey
        {
            get
            {
                return "type";
            }
        }

        /// <summary>
        /// 添加微博时带的扩展信息查询KEY，如@某人时是某人的name
        /// </summary>
        public static string AddStatusMetaParameterKey
        {
            get
            {
                return "meta";
            }
        }

        /// <summary>
        /// 添加微博时带的扩展信息2查询KEY，如@某人时是微博预置的内容
        /// </summary>
        public static string AddStatusSubMetaParameterKey
        {
            get
            {
                return "metatwo";
            }
        }

        /// <summary>
        /// 用户名KEY
        /// </summary>
        public static string UserNameKey
        {
            get
            {
                return "name";
            }
        }

        /// <summary>
        /// 微博最大字数
        /// </summary>
        public static int MaxStatusContentCount = 140;

        /// <summary>
        /// 高敏感翻页
        /// </summary>
        public static bool HightDragSensitivity
        {
            get
            {
                return false;
            }
        }

        #region 公共方法
        /// <summary>
        ///获取控件的子控件
        /// </summary>
        /// <typeparam name="T">子控件类</typeparam>
        /// <param name="root">父控件</param>
        /// <returns></returns>
        public static T FindChildOfType<T>(DependencyObject root) where T : class
        {
            var queue = new Queue<DependencyObject>();
            queue.Enqueue(root);

            while (queue.Count > 0)
            {
                DependencyObject current = queue.Dequeue();
                for (int i = VisualTreeHelper.GetChildrenCount(current) - 1; 0 <= i; i--)
                {
                    var child = VisualTreeHelper.GetChild(current, i);
                    var typedChild = child as T;
                    if (typedChild != null)
                    {
                        return typedChild;
                    }
                    queue.Enqueue(child);
                }
            }
            return null;
        }

        /// <summary>
        /// 是否是快速发微，当从快速发微瓦片进入是，add.xaml可以检查此参数
        /// </summary>
        public static string IsQuickAddStatusParameterKey
        {
            get
            {
                return "quickadd";
            }
        }

        #endregion
    }
}
